.chat-message-line {
    display: flex;
    padding: 6px 16px;
    gap: 8px;
    text-align: left;

    &.is-reverse {
        flex-direction: row-reverse;
        text-align: right;

        .chat-message-user {
            flex-direction: row-reverse;
        }
    }
}

.chat-message-user-avatar {
    display: inline-block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: #fff;
    font-size: 0;

    &>img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

.chat-message-user {
    padding-bottom: 4px;
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    line-height: 1.5;
}

.chat-message-user-name {
    color: var(--text);
    overflow: hidden;
    display: inline-block;
    text-overflow: ellipsis;
}

.chat-message-user-time {
    color: var(--text-weaker);
    flex-shrink: 0;
}

.chat-message-bubble {
    display: inline-block;
    padding: 4px 12px;
    color: var(--primary-stronger);
    background: var(--blue-0);
    border: 1px solid var(--blue-1);
    border-radius: 6px;
    user-select: text;
    position: relative;

    &.is-self {
        color: var(--blue-0);
        background: var(--primary);
        border-color: transparent;
        border-radius: 4px;
    }

    &>pre {
        margin: 0;
        padding: 0;
        overflow: visible;
        line-height: 24px;
        text-align: initial;
        font-family: inherit;
        white-space: normal;
        word-break: break-all;
        overflow-wrap: break-word;
        hyphens: auto;
        user-select: auto;
    }

    &::after {
        content: "";
        display: inline-block;
        width: 12px;
        height: 12px;
        position: absolute;
        left: -6px;
        top: 6px;
        border-left: 6px solid var(--blue-0);
        border-top: 6px solid transparent;
        border-bottom: 6px solid transparent;
        border-right: 6px solid transparent;
        transform: rotate(-45deg);
        transform-origin: 50% 50%;
    }

    &.is-self::after {
        left: unset;
        right: -6px;
        transform: rotate(-135deg);
        border-left-color: var(--primary);
    }
}

.chat-message-notice {
    color: var(--text-weak);
    font-size: 12px;
    text-align: center;
    flex: 1;
    user-select: none;
}

.chat-message-ban {
    flex: 1;
    text-align: center;

    &>span {
        display: inline-block;
        padding: 2px 12px;
        font-size: 12px;
        color: var(--text-weak);
        user-select: none;
    }
}

.chat-message-user-guide-bubble {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    user-select: text;
    background: var(--grey-0);
    color: var(--text);

    &>pre {
        margin: 0;
        padding: 0;
        overflow: visible;
        text-align: initial;
        font-family: inherit;
        white-space: normal;
        word-break: break-all;
        overflow-wrap: break-word;
        hyphens: auto;
        user-select: auto;
    }
}

.chat-message-user-guide-btn {
    color: var(--primary);
    cursor: pointer;
}

.flat-color-scheme-dark {
    .chat-message-user-avatar {
        background: var(--grey-8);
    }

    .chat-message-user-time {
        color: var(--grey-6);
    }

    .chat-message-bubble {
        background: var(--grey-8);
        border-color: transparent;

        &.is-self {
            color: var(--grey-0);
            background: var(--primary);
        }

        &::after {
            border-left-color: var(--grey-8);
        }

        &.is-self::after {
            border-left-color: var(--primary);
        }
    }

    .chat-message-user-guide-bubble {
        background: var(--grey-11);
    }

    .chat-user-status.is-teacher {
        color: var(--grey-6);
    }
}